import LoginForm from '../LoginForm';
import AdminPanel from '../AdminPanel';
import { useState, useEffect } from 'react';

export default function JudgeLogin() {
  const [isLogginedIn, setIsLogginedIn] = useState(false);

  useEffect(() => {
    // 将定时器限制在组件生命周期内
    const interval = setInterval(() => {
      setIsLogginedIn((prev) => !prev);
    }, 1000);
    return () => {
      clearInterval(interval); // 清理旧定时器
    }; //
  }, []); // 空依赖表示只在挂载/卸载时运行
  return (
    <>
      {isLogginedIn ? <AdminPanel /> : <LoginForm />}
    </>
  );
}
